home *** CD-ROM | disk | FTP | other *** search
- /*
- CDDiscTitle - An XFCN to report the title of the disc, if one has been entered
- ©Apple Computer, Inc. 1988
- All Rights Reserved.
-
- 88/11/08 BL°B First Version
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- C CDDiscTitle.c
- link -sn Main=CDDiscTitle -sn STDIO=CDDiscTitle ∂
- -sn INTENV=CDDiscTitle -rt XFCN=42 ∂
- -m CDDISCTITLE CDDiscTitle.c.o "{CLibraries}"CRuntime.o ∂
- "{CLibraries}"StdCLib.o ∂
- -o HyperCommands
-
- This link directive puts the XCMD in the file "HyperCommands".
- Substitute the name of the stack you want it in. To move XCMDs
- between stacks, use ResEdit. They can be in an individual stack,
- the Home stack, the HyperCard application, or the System File.
-
- */
-
- #include <cd.h>
- #include <ToolUtils.h>
-
- /* prototype definitions for functions */
- OSErr FindTitle(unsigned long, Str255 *);
-
- /* **** WARNING: DO NOT USE GLOBAL VARIABLES! **** */
-
-
- /************************************************************************
- *
- * Function: CDDiscTitle
- *
- * Purpose: return the title of this disc.
- *
- * Returns: a string, or empty
- *
- * Side Effects:
- *
- * Description: We need no parameters:
- * Get the ioRefNum that we got from previously calling
- * CDOpen() by accessing the famous global
- * call the driver with a READTOC call to find out
- * the lead-out time. This is a unique number for each
- * disc. Look in the System Folder for the file
- * "CD Remote Programs". Open that file, look at the
- * IndX resource to find out if we've got a matching
- * index. If we do, look up the STR# resource
- * referenced and return the first STR from that list.
- *
- ************************************************************************/
- pascal void
- CDDiscTitle(paramPtr)
- XCmdBlockPtr paramPtr;
- {
- OSErr result;
- short ioRefNum;
- Handle refHandle;
- unsigned long discID;
- Str255 title;
- Str31 returnString;
-
- strcpy(title, "\p");
-
- /* Must be no parameters */
- if ((paramPtr->paramCount) != 0)
- {
- /* Report error in parameters by returning -1 */
- NumToStr(paramPtr, (long) -1, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- return;
- }
-
- /* Get the global ioRefNum and convert it. */
- refHandle = GetGlobal(paramPtr, GLOBALNAME);
- ioRefNum = atoi(*(refHandle));
- DisposHandle(refHandle);
- ioRefNum &= 0xFFFF; /* remove vRefNum; not needed. */
-
- result = IDDisc(ioRefNum, &discID);
-
- if (discID == 0)
- return; /* empty string return if we can't ID the disc */
-
- result = FindTitle(discID, &title);
-
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &title);
- }
-
-
-
- /************************************************************************
- *
- * Function: FindTitle
- *
- * Purpose: Find disc title, given the disc ID
- *
- * Returns: OSErr. Usually noErr, but could have an error
- * in opening the CD Remote Programs file.
- *
- * Side Effects: fills in title with found title
- *
- * Description: open the file "CD Remote Programs". Look at the
- * 'IndX' resource to find out if we have a title.
- * If we can't find the appropriate 'IndX' resource,
- * set the title to blank and return. If we find
- * the appropriate IndX resource, open the associated
- * STR# resource and return the first string.
- *
- ************************************************************************/
- OSErr
- FindTitle(discID, title)
- unsigned long discID;
- Str255 *title;
- {
- OSErr result;
- short strListID; /* holds the 'STR#' resource id. */
- short resFile;
- Str255 fileName;
-
- result = noErr;
-
- GetIndString(fileName, STR_ID, DRIVENAME);
- if (fileName == (Str255)0)
- result = ResError();
-
- if (result == noErr)
- {
- resFile = OpenSystemResFile(fileName);
- if (resFile == -1)
- result = ResError();
- }
-
- if (result == noErr)
- if (FindIndex(discID, &strListID) == true)
- GetIndString(title, strListID, 1); /* fills in title */
-
- CloseResFile(resFile);
- return result;
- }
-
-
- /* C routines for HyperCard callbacks */
- #include <XCmdGlue.inc.c>
-